﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SheepStorage.API.Application.Command.EarTagCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.InputDto;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;

namespace SheepStorage.API.Controllers
{
    /// <summary>
    /// 产羔耳标
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class EarTagController : ControllerBase
    {
        private readonly IMediator _mediator;
        private readonly IEarTagService _earServ;

        public EarTagController(IMediator mediator, IEarTagService earServ)
        {
            _mediator = mediator;
            _earServ = earServ;
        }
        /// <summary>
        /// 耳标列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<Domain.DTO.Output.PageOutput<EarTagTable>>> GetEarTags(EarTagSelectCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 耳标添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> AddEarTags(EarTagAddCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 耳标单删
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> DelEarTags(EarTagDeleteCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 耳标批量删
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> BatchDelEarTags(EarTagBatchDelCommand command)
        {

            return await _mediator.Send(command);
        }
        /// <summary>
        /// 耳标反填
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<EarTagTable>> GetEarTag(EarTagEditCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 耳标修改
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> UpdEarTags(EarTagUpdateCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 耳号列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public IActionResult GetIdList()
        {
            var list=_earServ.GetIdList();
            return Ok(list);
        }
    }
}

